<!DOCTYPE html><html><head><meta charset="UTF-8"><title>HC1 Comments</title><style>
    .comment {
      overflow: hidden;
      padding: 18px 0 7px 0;
      clear: both;
    }

    .comment + .comment {
      border-top: 1px solid #e8e8e8;
    }

    .comment > .json {
      display: none;
    }

    .comment-box {
      background-color: #fffbe1;
      overflow: hidden;
      padding: 6px 12px;
      margin-bottom: 8px;
    }

    .reply-box {
      background-color: #eff2f9;
      padding: 6px 12px 6px 6px;
      overflow: hidden;
      margin-bottom: 8px;
    }

    .user-name {
      font-weight: bold;
      padding-right: 10px;
    }

    .comment > .author-picture {
      float: left;
      padding: 0 20px;
    }

    .reply-box > .author-picture {
      float: left;
      padding: 0 6px;
    }

    .comment-deleted {
      color: red;
      padding-right: 10px;
    }

    .author-picture + div, .user-name, .user-name + .comment-deleted, .user-name + .comment-action {
      float: left;
    }

    .created-date {
      color: #999;
    }

    .comment-box .comment-content {
      clear: both;
    }

    .comment-box > .created-date {
      float: right;
    }

    .reply-box .created-date {
      clear: both;
    }

    .comment-context-intro {
      color: #999;
      clear: both;
    }

    .comment-context-value {
      border-left: 1px solid #ccc;
      font-style: italic;
      padding: 3px 10px 3px 10px;
    }

    .comment-action {
      font-style: italic;
    }

    .comment-status {
      font-style: italic;
      color: green;
      float: left;
      font-weight: bold;
      padding-right: 10px;
    }
  </style></head><body><section class="header"><h1>HC1 - Drive File Comments</h1></section><section><div id="AAAASkmQsbg" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Evan Ovadia</div><div class="comment-status"></div><div class="created-date">Dec 22, 2021, 2:02 AM</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">&amp;amp;mut Jack</div></div><div class="comment-content">clean up Jack vs Pirate, maybe use a Cannon instead of Jack?</div></div><div class="reply-list"></div></div></div><div id="AAAASkmQsbY" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Evan Ovadia</div><div class="comment-status"></div><div class="created-date">Dec 22, 2021, 1:52 AM</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">won&amp;#39;t crash</div></div><div class="comment-content">Clarify won&#39;t crash; Vec index out of bounds can crash. Also, what if we use try_ or get() instead</div></div><div class="reply-list"></div></div></div><div id="AAAATjNqFco" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Evan Ovadia</div><div class="comment-status">Resolved</div><div class="created-date">Dec 21, 2021, 10:34 PM(edited: Dec 22, 2021, 1:35 AM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">parameter-borrowing shared mutability</div></div><div class="comment-content">explain this term better</div></div><div class="reply-list"><div id="AAAASkmQsZ4" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-action">Marked as resolved</div><div class="comment-content"></div><div class="created-date">Dec 22, 2021, 1:35 AM</div></div></div></div></div></div><div id="AAAATUD4F6k" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Evan Ovadia</div><div class="comment-status">Resolved</div><div class="created-date">Dec 21, 2021, 4:20 AM(edited: Dec 22, 2021, 1:58 AM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">reach the Vec holding Jack. That Vec will usually be in a place that&amp;#39;s reachable by any who might need it, it&amp;#39;s effectively global</div></div><div class="comment-content">make this clearer</div></div><div class="reply-list"><div id="AAAASkmQsbc" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-action">Marked as resolved</div><div class="comment-content"></div><div class="created-date">Dec 22, 2021, 1:58 AM</div></div></div></div></div></div><div id="AAAATUD4F6E" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14Gj7Mkk0yMyydzh5M2Sf78m8lRQk8ZhCpFlmXDlKBw=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Robert Grosse</div><div class="comment-status"></div><div class="created-date">Dec 21, 2021, 3:21 AM(edited: Dec 21, 2021, 3:22 AM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">Blackbeard: &amp;quot;I&amp;#39;d say it&amp;#39;s because it can&amp;#39;t handle shared mutability, which seems very common in real-world situations. If Drake and Ladbeard each point at Jack, and any one of them can draw an anchor on his face, they all have shared mutable access to him. But the borrow checker doesn&amp;#39;t let them have mutable references to them.&amp;quot;</div></div><div class="comment-content">This is the part you lost me, as it is straight out false. A better way to word it is that &quot;the borrow checker doesn&#39;t let them have <b>exclusive</b> references to them&quot;, in which case the mistake should be obvious. You can use Cell/Atomic all you want, and the fact that Redbeard doesn&#39;t point that out either will make Rustaceans think you don&#39;t know what you&#39;re talking about.</div></div><div class="reply-list"><div id="AAAATUD4F6M" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">its good that you brought up cell. ill add to the article what i explained on discord re cell. thanks!</div><div class="created-date">Dec 21, 2021, 3:22 AM</div></div></div></div></div></div><div id="AAAATUD4F54" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Evan Ovadia</div><div class="comment-status">Resolved</div><div class="created-date">Dec 21, 2021, 2:46 AM(edited: Dec 21, 2021, 10:34 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">effectively shared mutability</div></div><div class="comment-content">need a better phrase here, one that captures that &quot;we have something that we can use to get mutable access to a thing&quot;</div></div><div class="reply-list"><div id="AAAATUD4F58" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">like shared check-out-ability, like we&#39;re checking out a book from the library</div><div class="created-date">Dec 21, 2021, 2:47 AM</div></div></div><div id="AAAATjNqFck" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-action">Marked as resolved</div><div class="comment-content"></div><div class="created-date">Dec 21, 2021, 10:34 PM</div></div></div></div></div></div><div id="AAAATT1FcMQ" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Jake Fecher</div><div class="comment-status"></div><div class="created-date">Dec 20, 2021, 10:37 PM</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">checking on every subscript, or &amp;quot;purely&amp;quot; do all of our modifications later, which are both safer.&amp;quot;</div></div><div class="comment-content">Borrow checking is tied to a whole Vec, so &quot;checking on every subscript&quot; is orthogonal to the AxM problem - it only checks that the index is within range. The borrow checker will still statically prevent two mutable references to the same element (and indeed prevent two mutable references to anywhere in the Vec). Getting around this safely likely means using a Vec&lt;RefCell&lt;T&gt;&gt;</div></div><div class="reply-list"></div></div></div><div id="AAAATTv0iUo" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Jake Fecher</div><div class="comment-status"></div><div class="created-date">Dec 20, 2021, 10:35 PM</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">&amp;quot;Very true! The borrow checker makes us rewrite our code so that we use indices, checking on every subscript, or &amp;quot;purely&amp;quot; do all of our modifications later, which are both safer.&amp;quot;</div></div><div class="comment-content">Maybe worth noting here that indices also still prevent us from holding two mutable references to an element (or indeed the whole Vec) at the same time, so &quot;checking on every subscript&quot; is actually not related to the borrow checker problem.</div></div><div class="reply-list"></div></div></div><div id="AAAATTv0iTw" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Jake Fecher</div><div class="comment-status"></div><div class="created-date">Dec 20, 2021, 10:17 PM(edited: Dec 20, 2021, 10:22 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">beard: &amp;quot;I feel like your design is fundamentally flawed. If the borrow checker disagrees with it, it&amp;#39;s probably an anti-pattern. You should probably refactor so that you don&amp;#39;t run into this problem.&amp;quot;<br><br>Blackbeard: &amp;quot;Are you saying that RAII and observers are also anti-patterns, then?&amp;quot;<br><br>Redbeard: &amp;quot;Hmm. Maybe. I&amp;#39;d never thought about those, I just kind of followed the borrow checker and what other people said, and it worked out well enough.&amp;quot;</div></div><div class="comment-content">There&#39;s an argument that can be made here with regard to multithreading</div></div><div class="reply-list"><div id="AAAATTv0iT0" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">Like, how if the borrow checker rejects something, then it&#39;s probably not thread-safe?</div><div class="created-date">Dec 20, 2021, 10:18 PM</div></div></div><div id="AAAATTv0iT4" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Jake Fecher</div><div class="comment-content">Sure, these designs with shared mutability likely aren&#39;t threadsafe and the solution probably means adding a Mutex or similar. Though this runs into the Mutex/RefCell not being considered for this article</div><div class="created-date">Dec 20, 2021, 10:20 PM</div></div></div><div id="AAAATTv0iUA" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">thats a good point, i&#39;ll see if i can fit it into this one, and if not, it&#39;ll definitely be in one of the subsequent parts. thanks!</div><div class="created-date">Dec 20, 2021, 10:22 PM</div></div></div></div></div></div><div id="AAAATTv0iTg" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Jake Fecher</div><div class="comment-status"></div><div class="created-date">Dec 20, 2021, 10:09 PM</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">We&amp;#39;d need to take a &amp;amp;mut World as a parameter to modify anything, but we can&amp;#39;t modify a trait from another crate.&amp;quot;</div></div><div class="comment-content">May also be worth explaining why such a trait wouldn&#39;t take a &amp;mut World parameter in the first place if the problem is so pervasive. E.g. why is a design like<br>trait ClickObserver&lt;W&gt; { fn click(&amp;mut self, world: &amp;mut W) }<br>rejected?<br>(presumably because self is stored within world and without a RefCell we cannot safely get mutable references to both)</div></div><div class="reply-list"><div id="AAAATTv0iTk" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">yep, that&#39;s exactly right. i&#39;ll mention that, good catch!</div><div class="created-date">Dec 20, 2021, 10:09 PM</div></div></div></div></div></div><div id="AAAATTv0iTc" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Jake Fecher</div><div class="comment-status"></div><div class="created-date">Dec 20, 2021, 10:04 PM</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">Their solution is basically to add a full message-passing framework to communicate between components.&amp;quot;</div></div><div class="comment-content">Could be worth mentioning that I believe this solution also requires shared mutability in some form - a global top-level ui object, RefCells etc</div></div><div class="reply-list"></div></div></div><div id="AAAATTv0iSk" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Jake Fecher</div><div class="comment-status"></div><div class="created-date">Dec 20, 2021, 9:40 PM(edited: Dec 20, 2021, 9:42 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">t&amp;#39;s because in RAII, an object will affect the outside world. To do that, an object needs to either take in a &amp;amp;mut parameter, or hold an &amp;amp;mut member</div></div><div class="comment-content">The &quot;Can&#39;t do RAII&quot; section seems based on the assumption shared mutability is the only way to access/change things, though this is also possible and commonly done through RefCell/Mutex. Do we consider these to be shared mutability since they let multiple things change another, just not at the same time?<br>If we don&#39;t consider them shared mutability - RAII then doesn&#39;t require shared mutability since it can be done through RefCells/Mutexes.<br>If we do consider them shared mutability - then the statement of rust not having RAII is malformed since we can do it without extra parameters. I&#39;d agree that the borrow checker needs to be escaped through unsafe in some form, though I don&#39;t see this as an issue if its through safe abstractions like RefCell that withhold AxM</div></div><div class="reply-list"><div id="AAAATTv0iSs" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">My bad for not making this clearer from the start: I consider RefCell to be a workaround for the borrow checker, and a very good one, but the article is just about the borrow checker.<br><br>A few times I mistakenly say &quot;Rust can&#39;t&quot; when it&#39;s really &quot;the borrow checker can&#39;t&quot;, which is confusing, cleaning those up now.</div><div class="created-date">Dec 20, 2021, 9:42 PM</div></div></div></div></div></div><div id="AAAATTvzsQ0" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Jake Fecher</div><div class="comment-status"></div><div class="created-date">Dec 20, 2021, 9:19 PM(edited: Dec 20, 2021, 9:39 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">but only works for a given scope, so is more like try-finally than RAII.</div></div><div class="comment-content">I&#39;m not sure where you got this from, rust&#39;s RAII is almost exactly C++&#39;s RAII but with destructive moves</div></div><div class="reply-list"><div id="AAAATTv0iSg" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">This is referring to that smart-pointer-with-a-deleter approach, I&#39;ll remove the comma after &quot;deleter&quot; which should make it a little clearer.</div><div class="created-date">Dec 20, 2021, 9:39 PM</div></div></div></div></div></div><div id="AAAATTvzsQI" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Jake Fecher</div><div class="comment-status">Resolved</div><div class="created-date">Dec 20, 2021, 9:14 PM(edited: Dec 22, 2021, 2:07 AM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">&amp;quot;Rust won&amp;#39;t like this. Our structs generally don&amp;#39;t contain borrow references. Missile&amp;#39;s Plane targetPlane; should probably be a target_plane_index: u64; instead. And, to prevent other borrowing errors, we turn that missile parameter into some indices:<br><br>fn act(world: &amp;amp;mut World, plane_index: u64, missile_index: u64) {<br>  let target_plane_index = missile.target_plane_index;<br>  let target_plane_pos = world.planes[target_plane_index];<br>  let missile = world.planes[plane_index].missiles[missile_index];<br>  missile.position = missile.position.towards(target_plane_pos);<br>}<br><br>Blackbeard: &amp;quot;Indeed! But notice how we&amp;#39;re passing the entire World in. Because structs can&amp;#39;t refer to each other by index, we often have to pass the entire world as a parameter, making the world effectively global. Not great for encapsulation.&amp;quot;<br><br>Redbeard: &amp;quot;Why pass in the entire World? Why not just the planes array?&amp;quot;<br><br>Blackbeard: &amp;quot;That works for a while, until your planes need to affect something else, such as a base.&amp;quot;</div></div><div class="comment-content">Another option here is to just use a Rc&lt;RefCell&lt;Plane&gt;&gt; for the targetPlane reference which more closely mimics what the java code was doing and obviates the need for a world parameter</div></div><div class="reply-list"><div id="AAAATTv0iSc" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">I&#39;ll need to make this more clear in the beginning; the article is about using the borrow checker and not things like RefCell.</div><div class="created-date">Dec 20, 2021, 9:38 PM</div></div></div><div id="AAAASkmQsbk" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">clarified above!</div><div class="created-date">Dec 22, 2021, 2:07 AM</div></div></div><div id="AAAASkmQsbo" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-action">Marked as resolved</div><div class="comment-content"></div><div class="created-date">Dec 22, 2021, 2:07 AM</div></div></div></div></div></div><div id="AAAATTvzsP8" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Jake Fecher</div><div class="comment-status"></div><div class="created-date">Dec 20, 2021, 9:08 PM(edited: Dec 20, 2021, 9:54 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">&amp;quot;I assume it&amp;#39;s because people are coming from languages like Python and C and Java, which taught them to program without a borrow checker, but I honestly don&amp;#39;t know; all we have is anecdata on the subject. What do you think?&amp;quot;</div></div><div class="comment-content">Not sure if this is relevant here, but I found coming to rust from C++ made learning it a lot easier for me. In a lot of ways it felt like it was just enforcing the best practices of ownership and smart pointers in C++.</div></div><div class="reply-list"><div id="AAAATTv0iSY" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">I did as well, yet the borrow checker was hard to learn at the time. I&#39;ll include C++ instead of C here.<br><br>I&#39;ve often heard people say that Rust is enforcing the best practices in C++, but as hard as I look, I can&#39;t see it. Any idea what people mean by that?</div><div class="created-date">Dec 20, 2021, 9:37 PM</div></div></div><div id="AAAATTv0iS4" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Jake Fecher</div><div class="comment-content">For me at least, I was taught idiomatic/modern C++ meant using smart pointers and thinking about who owns your data so you know better when to copy and when you should take/hand out references.<br>Rust then makes the smart pointer approach more standard since it doesn&#39;t have C++&#39;s legacy of being &quot;C with classes.&quot; The borrow checker then covers the points on references, preventing you from making mistakes at the cost of not allowing all patterns.</div><div class="created-date">Dec 20, 2021, 9:54 PM</div></div></div></div></div></div><div id="AAAATTvzsPU" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Jake Fecher</div><div class="comment-status"></div><div class="created-date">Dec 20, 2021, 9:03 PM(edited: Dec 20, 2021, 10:15 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">pure functions</div></div><div class="comment-content">I agree with the comment saying this section needs more explaining why pure functions are encouraged. It also seems to take &quot;pure functions&quot; as meaning &quot;functions that do not mutate their arguments&quot; when it should mean &quot;functions that do not have any observable effects other than their return value&quot; - which also includes things like IO side effects through println which rust does not discourage. I believe I heard a closer term for &quot;no mutating parameters,&quot; but unfortunately I can&#39;t remember what it was now.</div></div><div class="reply-list"><div id="AAAATTv0iR4" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">Referential transparency maybe?</div><div class="created-date">Dec 20, 2021, 9:34 PM</div></div></div><div id="AAAATTv0iTo" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Jake Fecher</div><div class="comment-content">referential transparency would be a synonym for purity, maybe something like &quot;the borrow checker discourages mutability?&quot; Or encourages immutability</div><div class="created-date">Dec 20, 2021, 10:15 PM</div></div></div></div></div></div><div id="AAAATTvzsPE" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Jake Fecher</div><div class="comment-status"></div><div class="created-date">Dec 20, 2021, 9:00 PM(edited: Dec 20, 2021, 9:35 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">And it&amp;#39;s faster; normally the compiler would re-load data in case it changed, but now it doesn&amp;#39;t have to.</div></div><div class="comment-content">This seems to be a very small speed benefit for such functions - I&#39;d hesitate to call them faster at all since it is so minor and mutation general speeds up many operations (I say this as someone who likes pure FP).</div></div><div class="reply-list"><div id="AAAATTv0iSQ" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">Well said. I think I&#39;ll replace this entire section, the point is rather weak and hard to make</div><div class="created-date">Dec 20, 2021, 9:35 PM</div></div></div></div></div></div><div id="AAAATTtqrpQ" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Jake Fecher</div><div class="comment-status"></div><div class="created-date">Dec 20, 2021, 8:58 PM(edited: Dec 20, 2021, 10:05 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">This, coming from a nine-year veteran!&amp;quot;</div></div><div class="comment-content">The &quot;nine-year veteran&quot; backstories only seem to hurt the narrative imo since you as the writer of this story presumably do not have 9 years of experience in rust given v1.0 was in 2015</div></div><div class="reply-list"><div id="AAAATTv0iSU" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">I first used it in january 2013, perhaps I&#39;ll say &quot;coming from someone who&#39;s used it since the beginning!&quot; or something more vague.</div><div class="created-date">Dec 20, 2021, 9:36 PM(edited: Dec 20, 2021, 9:47 PM)</div></div></div><div id="AAAATTv0iTQ" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Jake Fecher</div><div class="comment-content">How often have you used it since then? I&#39;m only mentioning because this reads somewhat like an appeal to authority yet your first rust example had some issues. I&#39;d like to avoid the vague claims altogether and get right to the problems with the borrow checker - they should speak for themselves</div><div class="created-date">Dec 20, 2021, 10:02 PM</div></div></div><div id="AAAATTv0iTY" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">yep, this happens with every language i write about, i mix up the minor details of each. i used it a lot a couple years ago, to make a medium-sized roguelike game: <a href="https://www.google.com/url?q=https://www.reddit.com/r/roguelikedev/comments/i3xekn/ec_vs_ecs_for_roguelikes/&amp;sa=D&amp;source=docs&amp;ust=1653194667544387&amp;usg=AOvVaw32jrMK_nPhoEIJj4Oboq_t" data-rawhref="https://www.reddit.com/r/roguelikedev/comments/i3xekn/ec_vs_ecs_for_roguelikes/" target="_blank">https://www.reddit.com/r/roguelikedev/comments/i3xekn/ec_vs_ecs_for_roguelikes/</a><br><br>I changed it to &quot;someone who knows it so well&quot;. I hesitate to take it out, because otherwise everyone&#39;s first response to &quot;its unintuitive&quot; is &quot;you dont know it well yet&quot;</div><div class="created-date">Dec 20, 2021, 10:04 PM(edited: Dec 20, 2021, 10:05 PM)</div></div></div></div></div></div><div id="AAAATTtqrpI" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Jake Fecher</div><div class="comment-status">Resolved</div><div class="created-date">Dec 20, 2021, 8:57 PM(edited: Dec 20, 2021, 9:34 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">path[0]</div></div><div class="comment-content">This is invalid syntax, to construct a struct with this syntax the field needs a label like TakeStepAction { step: path[0] } alternatively TakeStepAction could be a tuple struct and be constructed using TakeStepAction(path[0]). It&#39;d probably be most idiomatic to use a function: TakeStepAction::new(path[0])</div></div><div class="reply-list"><div id="AAAATTv0iSE" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">thanks!</div><div class="created-date">Dec 20, 2021, 9:34 PM</div></div></div><div id="AAAATTv0iSI" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-action">Marked as resolved</div><div class="comment-content"></div><div class="created-date">Dec 20, 2021, 9:34 PM</div></div></div></div></div></div><div id="AAAATTtqrok" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a/AATXAJy3L6fzGF6tHo0CQ9eJ_bWzNQfys3xu8QQLNFM=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Jake Fecher</div><div class="comment-status">Resolved</div><div class="created-date">Dec 20, 2021, 8:38 PM(edited: Dec 20, 2021, 9:34 PM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">Opt</div></div><div class="comment-content">Opt should be Option here (I suppose it was cut for space?)</div></div><div class="reply-list"><div id="AAAATTv0iR8" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">Nope, this is just me confusing vale and rust again lol thanks!</div><div class="created-date">Dec 20, 2021, 9:34 PM</div></div></div><div id="AAAATTv0iSA" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-action">Marked as resolved</div><div class="comment-content"></div><div class="created-date">Dec 20, 2021, 9:34 PM</div></div></div></div></div></div><div id="AAAASIETsOw" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Evan Ovadia</div><div class="comment-status"></div><div class="created-date">Dec 20, 2021, 3:09 AM</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">Rust</div></div><div class="comment-content">must change this to borrow checker, and make it more consistent throughout</div></div><div class="reply-list"></div></div></div><div id="AAAASIETsOA" class="comment"><div class="json">null</div><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="48" height="48" alt="Author profile image"></div><div class="comment-data"><div class="comment-box"><div class="user-name">Evan Ovadia</div><div class="comment-status"></div><div class="created-date">Dec 20, 2021, 1:55 AM(edited: Dec 20, 2021, 6:19 AM)</div><div class="comment-context"><div class="comment-context-intro">Selected text:</div><div class="comment-context-value">the borrow checker encourages pure functions</div></div><div class="comment-content">must make this connection stronger, explain why the borrow checker encourages functional patterns</div></div><div class="reply-list"><div id="AAAASIETsOM" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">or perhaps take out this section. pure functions work really well in the borrow checker, but likely few will see it</div><div class="created-date">Dec 20, 2021, 2:20 AM</div></div></div><div id="AAAASIETsOQ" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">maybe replace with a different example of rust encouraging us into good patterns</div><div class="created-date">Dec 20, 2021, 2:25 AM</div></div></div><div id="AAAATPh0Jls" class="reply-box"><div class="author-picture"><img src="https://lh3.googleusercontent.com/a-/AOh14GjoOXwuji1Q0p6FX0IRu-PBtgN-CxWdF8wvbNemn1A=s50-c-k-no" width="24" height="24" alt="Author profile image"></div><div class="reply-data"><div class="user-name">Evan Ovadia</div><div class="comment-content">it encourages us into lots of arrays, which fits really well for things like ECS. fast to iterate.</div><div class="created-date">Dec 20, 2021, 6:19 AM</div></div></div></div></div></div></section></body></html>